
import {Vector} from '../vector' 

//线段
class Line {
  //起点、终点(Vector)
  constructor(tree_drawer, start_vec, end_vec) {
    this.tree_drawer = tree_drawer
    this.start = start_vec.Copy()
    this.end = end_vec.Copy()
  }

  //绘制
  Draw() {
    let cache = this.tree_drawer.cache
    let start_dest = cache.ConvertPosition(this.start)
    let end_dest = cache.ConvertPosition(this.end)
    this.tree_drawer.drawer.DrawLine(start_dest.x, start_dest.y, end_dest.x, end_dest.y)
  }

  //移动
  Move(vec) {
    this.start.Add(vec)
    this.end.Add(vec)
  }
}

module.exports = {
  Line
}